package Observer

type INotifier interface {
	AddObserver(observer IObserver)
	NotifyAll(message *Message)
}

type Notifier struct {
	ObserverList []IObserver
	NotifierName string
	INotifier
}

func NewNotifier(notifier string) *Notifier {
	return &Notifier{ObserverList: []IObserver{},
		NotifierName: notifier}
}

func (notifier *Notifier) AddObserver(observer IObserver) {
	notifier.ObserverList = append(notifier.ObserverList, observer)
}

func (notifier *Notifier) NotifyAll(message *Message) {
	for _, observer := range notifier.ObserverList {
		observer.Update(message, notifier)
	}
}
